package br.unicamp.ic.sgct.client.aplicacao.ucs;

import java.util.Date;

import br.unicamp.ic.sgct.client.SisGesConfTec;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.rpc.ServiceDefTarget;

public class UtilsFacade {
	private static String strDataFormatada = "";
	private static UtilsServiceAsync service;

	static {
		service = GWT.create(UtilsService.class);

		ServiceDefTarget target = (ServiceDefTarget) service;
		target.setServiceEntryPoint(SisGesConfTec.instance().getModuleRelativeURL()
				+ UtilsService._RELATIVE_PATH);
	}
	
	/**
	 * @see br.unicamp.ic.sgct.client.aplicacao.ucs.UtilsService#formatarData(java.util.Date)
	 */
	public static String formatarData(Date data) {
		System.out.println("Data sistema: " + data );
		
		service.formatarData(data, new AsyncCallback<String>() {
			public void onSuccess(String result) {
				strDataFormatada = result;
			}

			public void onFailure(Throwable caught) {
				; //nao faz nada por hora
			}
		});

		System.out.println("Data Formatada: " + strDataFormatada );
		return strDataFormatada;
	}
}